
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core">

<ui:composition template="/template_padrao.xhtml">

	<ui:define name="content">

		<f:event type="preRenderView" listener="#{cubMB.beginConversation()}" />
	

		<h2>Consulta CUB</h2>
		<h:form id="form_con_cub" enctype="multipart/form-data" prependId="false">
			<p:fieldset styleClass="fieldSetPadrao">
				<legend>Upload Arquivo (Somente arquivos *.xls)</legend>
				<p:fileUpload fileUploadListener="#{cubMB.importarArquivo}"
					showButtons="false" label="Selecione" cancelLabel="Cancelar"
					fileLimit="1" sizeLimit="10000000"
					allowTypes="/(\.|\/)(xls)$/"
					converterMessage="&#160;&#160;&#160;&#160;&#160; Arquivo Inválido."
					invalidFileMessage="&#160;&#160;&#160;&#160;&#160; Arquivo Inválido." 
					update="messages"/>
					
					<p:messages id="messages" /> 
					<div id="actionButton" class="buttonNew">	
					<a href="http://www.cbicdados.com.br/media/anexos/tabela_06.A.06_10.xlsx" class="link"> Download Planilha Atualizada</a>
				</div>
					

	
			</p:fieldset>
			<br />
			
			<p:fieldset>
				<legend>Pesquisa</legend>				
				<table >
					<tr>
						<td>
							
							<h:outputLabel value="Ano" styleClass="ob"/>
						</td>
						<td>
							<h:outputLabel value="Estado" styleClass="ob" />
						</td>
					</tr>					
					<tr>
						<td>
							<p:inputText value="#{cubMB.anoPesquisa}" 
										required="true" 
										label="ano" 
										id="anoPesquisa"> 
								<f:convertNumber integerOnly="true" type="number" />
							</p:inputText>
						</td>
						<td>
							<p:selectOneMenu value="#{cubMB.estadoSelecionado}" converter="converterEstado" required="true"   label="estado">
								<f:selectItems value="#{cubMB.listaEstados}" var="est" itemLabel="#{est.toString()}" />
							</p:selectOneMenu>
						</td>
						<td>
							<p:commandButton ajax="false" 
								action="#{cubMB.pesquisar()}" 
								value="Pesquisar" 
								update=":form_con_cub:chart_bar_cub"/>
						</td>
					</tr>
				</table>
				
				
			</p:fieldset>
			<br />

			<p:barChart id="chart_bar_cub" 
						value="#{cubMB.graficoBarras}"
						legendPosition="ne" 
						title="CUB Mensal" 
						min="#{cubMB.menorValorGrafico}" 
						max="#{cubMB.maiorValorGrafico}" 
						orientation="vertical"							
						animate="true" 						
						rendered="#{cubMB.graficoBarras != null}"/>
						
			<br />	
			

		</h:form>

	</ui:define>

</ui:composition>

</html>